home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / pbclon20.zip / QUESTION.TXT < prev    next >
Text File  |  1992-10-19  |  7KB  |  207 lines

  1.               Common Questions about QuickBASIC
  2.  
  3.  
  4.  
  5. After spending much time on CompuServe, BIX, the FidoNet
  6. QuickBASIC echo and other national BASIC forums, I've noticed
  7. that there is a lot of repetition. People ask the same
  8. questions, time after time.  They must be good questions! Here
  9. is a compilation of a few of the more common questions.
  10.  
  11.  
  12.  
  13. Question:
  14.    How can I disable Control-Break?
  15.  
  16. Answer:
  17.    Programs compiled with QuickBASIC or BASCOM usually don't
  18.    have to worry about this.  Control-Break is disabled unless
  19.    you compile with the /D (debug) option.  In the event that
  20.    you are doing something that QuickBASIC doesn't completely
  21.    control, like printing to the screen via DOS functions, this
  22.    protection no longer holds.  In that case, you may be able
  23.    to disable Break by getting DOS to check for it less
  24.    frequently.  Use the command
  25.       BREAK OFF
  26.    from a batch file, or execute it from BASIC like so:
  27.       SHELL "COMMAND BREAK OFF"
  28.  
  29.    See also the BreakOff routine in my PBClone library.
  30.  
  31.  
  32.  
  33. Question:
  34.    How can I get the error level from a SHELLed program?  How
  35.    can I get my program to return an error level?
  36.  
  37. Answer:
  38.    That requires assembly language.  PBClone contains such
  39.    routines.  Also, newer BASIC compilers let you include an
  40.    error level with your END statement.
  41.  
  42.  
  43.  
  44. Question:
  45.    How can I read the command line from BASIC?
  46.  
  47. Answer:
  48.    The COMMAND$ function will do it for you.  Note that
  49.    COMMAND$ doesn't return the exact command line-- it is
  50.    trimmed somewhat and capitalized.  The QBWiz library can
  51.    return the original command line for you.
  52.  
  53. Question:
  54.    How can I get access to COM3 and COM4 for my communications
  55.    program?
  56.  
  57. Answer:
  58.    BASIC doesn't provide support for those comm ports.
  59.    However, there are many add-on libraries which will let you
  60.    do it.  Look for BasWiz, QBCOM, or QBSER, among others.
  61.  
  62.  
  63.  
  64. Question:
  65.    How can I get a directory listing into an array?
  66.  
  67. Answer:
  68.    If you're using BASCOM/PDS, check the DIR$ function.  Also,
  69.    most BASIC libraries can do this for you.  Another way to do
  70.    this is to put the directory listing into a file by
  71.       SHELL "DIR *.* >DIRLIST.TXT"
  72.    and then read the file into an array.  Yet another
  73.    alternative is to use the FILES statement on a non-displayed
  74.    screen page (if you have a CGA, EGA or VGA) or in invisible
  75.    colors (say, black on black), then get the results from the
  76.    screen with the SCREEN function.
  77.  
  78.  
  79.  
  80. Question:
  81.    How can I see if a file exists?
  82.  
  83. Answer:
  84.    Most BASIC libraries can do this for you.  Or, you can use
  85.    the directory approach given above.  Yet another way to do
  86.    it is to try to open the file for input:
  87.  
  88.          ON ERROR GOTO NotFound
  89.          OPEN File$ FOR INPUT AS #1
  90.          CLOSE #1
  91.          Found = -1
  92.       Done:
  93.          RETURN
  94.       NotFound:
  95.          Found = 0
  96.          RESUME Done
  97.  
  98. Question:
  99.    I'm running out of string space.  What can I do?
  100.  
  101. Answer:
  102.    If you have arrays, try moving them outside of the string
  103.    space area. Either use REDIM to dimension 'em or use the REM
  104.    $DYNAMIC metacommand.  If this doesn't help enough, use
  105.    fixed-length strings, which are stored outside the regular
  106.    string area.  Still not enough room?  Try Microsoft's PDS or
  107.    VB-DOS compilers, or Spectra's PowerBASIC.  Also, my BasWiz
  108.    library provides "far strings" for QuickBasic.
  109.  
  110.  
  111.  
  112. Question:
  113.    I'd like to constantly display the time.  What do I do?
  114.  
  115. Answer:
  116.    That's also available in libraries, including PBClone.  You
  117.    can do it yourself using an approach like this, among other
  118.    ways:
  119.  
  120.          ON TIMER(1) GOSUB DisplayTime
  121.          TIMER ON
  122.          ' your program goes here
  123.       DisplayTime:
  124.          OldRow = CSRLIN
  125.          OldCol = POS(0)
  126.          LOCATE 25, 70
  127.          PRINT TIME$;
  128.          LOCATE OldRow, OldCol
  129.          RETURN
  130.  
  131.  
  132.  
  133. Question:
  134.    I need to know how many days lie in between two dates.  How
  135.    do I do it?
  136.  
  137. Answer:
  138.    As usual... this is something you can get in a library from
  139.    your local BBS.  Try PBClone or QB4BAS.
  140.  
  141. Question:
  142.    How can I use ANSI display codes?
  143.  
  144. Answer:
  145.    You need to go through DOS display functions for that to
  146.    work.  Use this:
  147.       OPEN "CON" FOR OUTPUT AS #1
  148.    This makes the DOS display functions available as file
  149.    (device) number one.  You can print to it using normal file
  150.    statements:
  151.       PRINT #1, CHR$(27); "[2J";
  152.    The above statement will clear the screen if an ANSI driver
  153.    is installed. See your DOS manual for information on the
  154.    available ANSI codes.  You can also get this information
  155.    from your friendly local BBS.
  156.  
  157.    If you are using the BasWiz library, check out ANSIprint in
  158.    the Telecommunications section.  It handles ANSI in a
  159.    virtual window and also allows for "ANSI" music processing
  160.    if desired.  ANSI.SYS not needed.
  161.  
  162.  
  163.  
  164. Question:
  165.    How can I print the screen to the printer, in text or
  166.    graphics mode?
  167.  
  168. Answer:
  169.    One simple solution is to use CALL INTERRUPT.  Interrupt
  170.    number 5 (five) does the same thing as pressing
  171.    PrintScreen/PrtSc on your keyboard.  It will handle CGA
  172.    graphics as well as text mode if GRAPHICS is installed
  173.    (GRAPHICS.COM or GRAPHICS.EXE is provided with DOS).
  174.  
  175.    If you are just using text mode, check into the SCREEN
  176.    function, which allows you to read characters off the
  177.    display.  If you collect each row into a string and then use
  178.    RTRIM$ to remove trailing blanks, it'll be faster than
  179.    sending all those meaningless blanks to the printer.
  180.  
  181. Question:
  182.    How can I display picture files, like GIF, PCX, MAC, MSP and
  183.    so forth?
  184.  
  185. Answer:
  186.    Well, the BasWiz library can help with MAC and PCX files.
  187.    Probably the best solution for a general-purpose picture
  188.    handler, though, would be to get a copy of OPTIKS (usually
  189.    distributed as OK followed by a version number) or another
  190.    picture format converter at your local BBS.  Image
  191.    translation tends to be somewhat difficult and slow in
  192.    BASIC, and it's hard to find the information needed to
  193.    handle the various formats available.  If you can read other
  194.    languages than BASIC, you can find source code for various
  195.    picture handlers on your local BBS.  These are often written
  196.    in assembly language, C, and Pascal, which are better for
  197.    this specific purpose than BASIC.
  198.  
  199.  
  200.  
  201. Have I mentioned BBSes a lot?!  If you don't have a modem, make
  202. the investment!  It will be well worth it, whether you are a
  203. serious programmer or just like to fiddle around now and then.
  204. There are vast numbers of files and helpful people within reach
  205. of a telephone call of your computer!
  206.  
  207.